package com.codebattery.service;

import com.codebattery.domain.entity.Dict;
import com.codebattery.domain.model.DictInfo;
import com.codebattery.repository.DictRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@CacheConfig(cacheNames = "Dict")
@Service
public class DictService {

    @Autowired
    private DictRepository dictRepository;

    @Cacheable(key="'list'")
    public List<Dict> findAllDicts(){
        return dictRepository.findAll();
    }

    public Page<DictInfo> queryDicts(Pageable pageable){
        return  dictRepository.queryDicts(pageable);
    }

}
